package com.ruoyi.web.controller.task;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.task.domain.SysTaskStep;
import com.ruoyi.task.service.ISysTaskStepService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务步骤Controller
 * 
 * @author YJF
 * @date 2022-12-08
 */
@RestController
@RequestMapping("/task/taskStep")
public class SysTaskStepController extends BaseController
{
    @Autowired
    private ISysTaskStepService sysTaskStepService;

    /**
     * 查询任务步骤列表
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTaskStep sysTaskStep)
    {
        startPage();
        List<SysTaskStep> list = sysTaskStepService.selectSysTaskStepList(sysTaskStep);
        return getDataTable(list);
    }

    /**
     * 根据条件查询任务步骤
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:list')")
    @GetMapping("/getAll")
    public AjaxResult getAll(SysTaskStep sysTaskStep)
    {
        return AjaxResult.success(sysTaskStepService.selectSysTaskStepList(sysTaskStep));
    }

    /**
     * 获取任务步骤详细信息
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysTaskStepService.selectSysTaskStepById(id));
    }


    /**
     * 新增任务步骤
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:add')")
    @Log(title = "任务步骤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTaskStep sysTaskStep)
    {
        return toAjax(sysTaskStepService.insertSysTaskStep(sysTaskStep));
    }

    /**
     * 修改任务步骤
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:edit')")
    @Log(title = "任务步骤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTaskStep sysTaskStep)
    {
        return toAjax(sysTaskStepService.updateSysTaskStep(sysTaskStep));
    }

    /**
     * 删除任务步骤
     */
    @PreAuthorize("@ss.hasPermi('task:taskStep:remove')")
    @Log(title = "任务步骤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysTaskStepService.deleteSysTaskStepByIds(ids));
    }
}
